package com.diploma.project.aiqiyi.exception;

import com.diploma.project.aiqiyi.common.enums.CommonOutputEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

	private static final long serialVersionUID = -5450301440861289229L;

	private Integer errorcode;

	private String description;

	public BusinessException(Integer code, String msg) {
		this.errorcode = code;
		this.description = msg;
	}

	public BusinessException(CommonOutputEnum outputEnum, Object... replaceMsg) {
		this.errorcode = outputEnum.getCode();
		this.description = String.format(outputEnum.getMsg(), replaceMsg);
	}

	public BusinessException replaceMsg(Object... replaceMsg) {
		this.description = String.format(description, replaceMsg);
		return this;
	}

}
